package org.example.api.goods.category.controller;

import org.example.api.goods.category.fallback.CategoryControllerFeignFallback;
import org.example.api.goods.category.request.CategoryCreateRequest;
import org.example.api.goods.category.request.CategorySearchWithLevelPageRequest;
import org.example.api.goods.category.request.CategorySearchWithLevelRequest;
import org.example.api.goods.category.response.CategorySummaryResponse;
import org.example.frw.api.base.intf.ID;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(
        name = "goods-server",
        contextId = "categories",
        fallback = CategoryControllerFeignFallback.class,
        path = "/goods-server"
)
public interface CategoryControllerFeign {
  /**创建一个分类
   * @param request request
   * @return 主键
   */
  @PostMapping("/category-manage/category")
  ID createCategory(@RequestBody CategoryCreateRequest request);

  /**查询分类
   * @param categorySearchRequest categorySearchRequest
   * @return 主键
   */
  @PostMapping("/category-manage/categories")
  List<CategorySummaryResponse> searchCategory(@RequestBody CategorySearchWithLevelPageRequest categorySearchRequest);

  /**查询分类数量
   * @param categorySearchRequest categorySearchRequest
   * @return 主键
   */
  @GetMapping("/category-manage/categories/count")
  Long searchCategoryCount(CategorySearchWithLevelRequest categorySearchRequest);

  /**查询分类数量
   * @param id categorySearchRequest
   * @return 主键
   */
  @GetMapping("/category-manage/categories/id/{id}")
  CategorySummaryResponse findOne(@PathVariable("id") Long id);

  /**隐藏一个分类
   * @param id id
   */
  @DeleteMapping("/category-manage/categories/id/{id}")
  void hide(@PathVariable("id") Long id);
}
